﻿using OpenAuth.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenAuth.Repository.Models.Mapping
{
    public class OAuth2AccountMap : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<OAuth2Account>
    {
        public OAuth2AccountMap()
        {
            // table
            ToTable("OAuth2Account", "dbo");

            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                .HasColumnName("Id")
                .IsRequired();
            Property(t => t.OAuthServer)
                .HasColumnName("OAuthServer")
                .HasMaxLength(255)
                .IsRequired();
            Property(t => t.Token)
                .HasColumnName("Token")
                .HasMaxLength(255)
                .IsRequired();
            Property(t => t.OpenID)
                .HasColumnName("OpenID")
                .IsRequired();
            Property(t => t.ExpireTime)
                .HasColumnName("ExpireTime")
                .IsRequired();

            Property(t => t.NickName)
                .HasColumnName("NickName")
                .IsRequired();

            Property(t => t.HeadUrl)
            .HasColumnName("HeadUrl")
            .IsRequired();

            Property(t => t.BindAccount)
            .HasColumnName("BindAccount")
            .IsRequired();
            // Relationships
        }
    }
}
